import java.util.*;


public class Solution9 {
    public static void main(String[] args) {
        //准备工作
        Solution9 s= new Solution9();
        List<String> stringList = s.letterCombinations("23");
        String s1 ="123";
        String substring = s1.substring(0, s1.length()-1);
        System.out.println(substring);
        Set<Integer> set = new HashSet<>();
    }
    private List<String> result = new ArrayList<String>();
    private Map<String,String> map = new HashMap<>();
    public List<String> letterCombinations(String digits) {
        //准备工作
        map.put("2","abc");
        map.put("3","def");
        map.put("4","ghi");
        map.put("5","ghi");
        map.put("6","jmno");
        map.put("7","pqrs");
        map.put("8","tuv");
        map.put("9","wxyz");
        String s= "";
        int n = digits.length();
        _combination(0,digits,n,s);
        return result;
    }
    private void _combination(int level,String digits,int n,String s){
        if(level == n){
            result.add(s);
            return;
        }
        String chooseStr = map.get(digits.substring(0,1));
        char[] chooseChars = chooseStr.toCharArray();
        for(int i =0;i<chooseStr.length();i++){
            s+=chooseChars[i];
            _combination(level+1,digits.substring(1),n,s);
            s = s.substring(0,s.length()-1);
        }
    }
}
